home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
726-750
/
744
/
fo2
/
sources_fo2
/
disk.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
3KB
|
142 lines
#include "defs.h"
Prototype WaitChangeDisk(BYTE drive1,BYTE drive2);
Prototype Change1D(BYTE drive);
Prototype isBlocUsed(WORD Bloc);
Prototype HowBlockUsed(LONG *AdrBM);
Prototype LoadBinMem();
Prototype Buffer(LONG m);
WaitChangeDisk(drive1,drive2)
BYTE drive1,drive2;
{
BYTE val;
BYTE state1=-1,state2=-1;
BYTE I1,I2,J1,J2;
BYTE drive;
val=0;
if (drive1 != (BYTE)-1) MtrOff(drive1);
if (drive2 != (BYTE)-1) MtrOff(drive2);
if (drive1==(BYTE)-1) return(Change1D(drive2));
if (drive2==(BYTE)-1) return(Change1D(drive1));
putIText("Now change Disks (source & dest) ");
I1=I2=J1=J2=1;
while ( (state1 % 2) || (state2 % 2) || (!state1) || (!state2) )
{
if (isInserted(drive1)) { state1+=I1; I1=0; J1=1;}
else { state1+=J1; J1=0; I1=1;}
if (isInserted(drive2)) { state2+=I2; I2=0; J2=1;}
else { state2+=J2; J2=0; I2=1;}
val=HandleIDCMP2(FOWin);
if (val==2) return(2);
if (val==1) exit(0);
Delay(10);
}
}
Change1D(drive)
BYTE drive;
{
BYTE val;
putIText("Now change Disk (dest) ");
while (!isInserted(drive))
{
val=HandleIDCMP2(FOWin);
if (val==2) return(2);
if (val==1) exit(0);
Delay(10);
}
while (isInserted(drive))
{
val=HandleIDCMP2(FOWin);
if (val==2) return(2);
if (val==1) exit(0);
Delay(10);
}
return(0);
}
/* isBlocUsed renvoie 1 si Block libre ou 0 si block occuppé
il se réfère au BitMap */
isBlocUsed(Bloc)
WORD Bloc;
{
LONG A,B;
if (Bloc==0 || Bloc==1) return(1); /* Faux car blocks used mais pratique ! */
A=*(BBM+1+(Bloc-2)/32);
B=(A>>(((Bloc-2)%32)) & 0x1L);
return(B);
}
HowBlockUsed(AdrBM)
LONG *AdrBM;
{
WORD i,TotalBlocks=0;
for (i=2;i<=1760;i++)
{
TotalBlocks+=(WORD)!(isBlocUsed(i));
}
return(TotalBlocks);
}
LoadBinMem()
{
LONG n,m=0;
LONG *buff1,*buff2,*inCHIP;
struct DiskList *dlist;
BYTE val;
inCHIP=VarAdr->inCHIP;
putIText("Reading Source and preparing ... ");
for (n=2;n<1760;n++)
{
if (isBlocUsed(n)==used)
{
val=HandleIDCMP2(FOWin);
if (val)
{
if (val==1) exit(0);
if (val==2) return(2);
}
buff1=(LONG *)(Buffer(m++));
if (TypeOfMem(buff1)&MEMF_CHIP) buff2=buff1;
else buff2=inCHIP;
if (Read_WriteB(R,(LONG)sourceDrive,buff2,n))
{
putIText("Read Error, can' t optimize ");
return(2);
}
if (buff2==inCHIP) CopyMemQuick(buff2,buff1,512L);
#ifdef DEBUG
if (!Buffer(m-1))
{
puts("Problème avec LoadBinMem !");
exit(0);
}
#endif
Organising(buff1,dlist,n);
}
if ((n%22)==0) printCYL(n/22);
}
return(0);
}
/* Cherche et renvoie l' adresse oû ranger le bloc */
Buffer(m)
LONG m;
{
return((*VarAdr->TableMem)[m]);
}